<?php
class Arm_Db_Select extends Zend_Db_Select{

    public function clearColumns(){
   
        $parts = $this->_parts;
        $parts['columns'] = array();
        $this->_parts = $parts;
    }

    public function setColumns($columns = array()){
    
        $this->clearColumns();
        if(is_array($columns)){
            foreach($columns as $column){
                $s = explode('.',$column);
                $this->addColumn($s[0],$s[1]);
            }
        }else{
            $s = explode('.',$columns);
            $this->addColumn($s[0],$s[1]);
        }
    }

    public function addColumn($table, $column = '*', $sc = null){
        
        $columns = $this->_parts['columns'];
        array_push($columns,array($table,$column,$sc));

        $this->_parts['columns'] = $columns;
    }

    /* Filtra dados excluidos logicamente
     */
    public function active($path = Null){
    
        $where = is_null($path) ? '' : $path . '.';
        $where .= 'active = True';
        $this->where($where);
        return $this;
    }

    /* Filtra dados não excluidos logicamente
     */
    public function inactive($path = Null){

        $where = is_null($path) ? '' : $path . '.';
        $where .= 'active = False';
        $this->where($where);
        return $this;
    }
}
